package com.qiguliuxing.dts.admin.web;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.qiguliuxing.dts.admin.annotation.RequiresPermissionsDesc;
import com.qiguliuxing.dts.admin.util.AuthSupport;
import com.qiguliuxing.dts.core.util.ResponseUtil;
import com.qiguliuxing.dts.core.validator.Order;
import com.qiguliuxing.dts.core.validator.Sort;
import com.qiguliuxing.dts.db.domain.DtsAd;
import com.qiguliuxing.dts.db.domain.DtsLivestream;
import com.qiguliuxing.dts.db.service.DtsAdService;
import com.qiguliuxing.dts.db.service.DtsLiveStreamService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/livestream")
@Validated
public class LiveStreamController {
	private static final Logger logger = LoggerFactory.getLogger(LiveStreamController.class);

	@Autowired
	private DtsLiveStreamService dtsLiveStreamService;

	@GetMapping("/addandlist")
	public Object addandlist() {
		logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 直播->广告管理->删除,请求参数:ad:{}", "ddddddd");
		DtsLivestream liveStream = dtsLiveStreamService.findById(1);
		liveStream.setClickcount(liveStream.getClickcount()+1);
		dtsLiveStreamService.updateById(liveStream);
		logger.info("【请求结束】直播->广告管理->删除,响应结果:{}", "成功");
		return ResponseUtil.ok(liveStream);
	}
//	@RequiresPermissions("admin:ad:delete")
//	@RequiresPermissionsDesc(menu = { "推广管理", "广告管理" }, button = "删除")
	@GetMapping("/list")
	public Object list() {
		logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 直播->广告管理->删除,请求参数:ad:{}", "ddddddd");
		DtsLivestream liveStream = dtsLiveStreamService.findById(1);
		System.out.println(liveStream.getClickcount());
		logger.info("【请求结束】直播->广告管理->删除,响应结果:{}", "成功");
		return ResponseUtil.ok(liveStream);
	}
	@GetMapping("/add")
	public Object add() {
		logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 直播->广告管理->删除,请求参数:ad:{}", "ddddddd");
		DtsLivestream liveStream = dtsLiveStreamService.findById(1);
		liveStream.setClickcount(liveStream.getClickcount()+1);
		dtsLiveStreamService.updateById(liveStream);
		logger.info("【请求结束】直播->广告管理->删除,响应结果:{}", "成功");
		return ResponseUtil.ok();
	}

}
